<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>

<!-- Authors: Mareike, David -->

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="jquery/jquery-latest.js"></script>
<script type="text/javascript" src="jquery/jquery.tablesorter.js"></script>
<script type="text/javascript">
<!--
	$(document).ready(function() {
		$("#myTable").tablesorter({
			sortList : [ [ 0, 0 ] ]
		});
	});
//-->
</script>

<title>Admin Add Stall Page</title>
</head>
<c:if test="${staffmember == null}">
	<jsp:forward page="Login.jsp" />
</c:if>

<c:choose>
	<c:when test="${empty cookie}">
		<jsp:forward page="Login.jsp" />
	</c:when>
	<c:otherwise>
		<!--  if the mossStreetMarketCookie has been set but the username is not in the session object -->
		<c:forEach var="cookieVal" items="${cookie}">
			<c:if test="${cookieVal.key == 'mossStreetMarketCookie'}">
				<c:if test="${empty sessionScope.username}">
					<jsp:forward page="Login.jsp" />
				</c:if>
			</c:if>
		</c:forEach>
	</c:otherwise>
</c:choose>

<body>

	<div class="main">
		<div class="header">
			<div class="header_resize">
				<div class="logo">
					<h1>
						<span>MossStreet</span>Market <small>Organic food,
							pottery, clothing ... just for you</small>
					</h1>
				</div>
				<div class="clr"></div>
				<div class="menu_nav">
					<ul>
						<li><a href="Admin.jsp">Admin</a></li>
						<li class="active"><a href="AddStall.jsp">Add/Modify
								Stall</a></li>
						<li><a href="AdminAddUser.jsp">Add/Modify User</a></li>
						<li><a href="AdminAddBooking.jsp">Add/Delete Booking</a></li>
					</ul>
				</div>
				<div class="clr"></div>
			</div>
		</div>
		<div class="content">
			<div class="content_resize">
				<div class="mainbar_long">
					<div class="article">
						<h2>
							<span>Admin Add Stall Page. Welcome <c:out
									value="${username}" /> !
							</span>
						</h2>
						<div class="clr"></div>
						<%@page import="java.sql.Connection"%>
						<%@page import="com.moss.street.market.DerbyDatabase"%>
						<%@page import="com.moss.street.market.StallsBean"%>

						<%
							Connection conn = DerbyDatabase.getConnInstance();
							StallsBean sb[] = DerbyDatabase.stallsList(conn);
						%>
						<h3>Existing Stalls</h3>
						<table id="myTable" class="tablesorter">
							<thead>
								<tr>
									<th>Stall Number</th>
									<th>Stall Type</th>
									<th>Length (cm)</th>
									<th>Width (cm)</th>
									<th>Fee (CDN$)</th>
								</tr>
							</thead>
							<%
								if (sb != null) {
									for (int i = 0; i < sb.length; i++) {
							%>
							<tr>
								<td><%=sb[i].getStallNumber()%></td>
								<td><%=sb[i].getStallType()%></td>
								<td><%=sb[i].getLength()%></td>
								<td><%=sb[i].getWidth()%></td>
								<td><%=sb[i].getFee()%></td>
							</tr>
							<%
								}
								}
							%>
						</table>
						<br> <br>
						<form method="post" action="AdminServlet">
							<h3>Add A New Stall</h3>
							<table>
								<thead>
									<tr>
										<th>Stall Number</th>
										<th>Stall Type</th>
										<th>Length (cm)</th>
										<th>Width (cm)</th>
										<th>Fee (CDN$)</th>
									</tr>
								</thead>
								<tr>
									<td><input type="text" value="" name="stallnumber" size=4></td>
									<td><input type="text" value="" name="stalltype" size=20></td>
									<td><input type="text" value="" name="stalllength"
										size="4"></td>
									<td><input type="text" value="" name="stallwidth" size="4"></td>
									<td><input type="text" value="" name="stallfee" size="4"></td>
								<tr>
									<td colspan="5" align="left"><input type="submit"
										value="Add Stall"></td>
								</tr>
							</table>
						</form>

						<br>
						<form method="post" action="AdminServlet">
							<h3>Modify A Stall</h3>
							<i>Hint: The stall number is used to locate the record so it
								can not be modified. All the other fields can be changed. Fields
								left empty will not be modified.</i>
							<table>
								<thead>
									<tr>
										<th>Stall Number</th>
										<th>Stall Type</th>
										<th>Length (cm)</th>
										<th>Width (cm)</th>
										<th>Fee (CDN$)</th>
									</tr>
								</thead>
								<tbody>
									<tr>
										<td><input type="text" value="" name="modifystallnumber"
											size=4></td>
										<td><input type="text" value="" name="modifystalltype"
											size=20></td>
										<td><input type="text" value="" name="modifystalllength"
											size="4"></td>
										<td><input type="text" value="" name="modifystallwidth"
											size="4"></td>
										<td><input type="text" value="" name="modifystallfee"
											size="4"></td>
									<tr>
										<td colspan="5" align="left"><input type="submit"
											value="Modify Stall"></td>
									</tr>
								</tbody>
							</table>
						</form>
						<br> <br>
						<hr>
						<form method="post" action="Admin.jsp">
							Return to Admin Page.<br> <br> <input type="submit"
								name="admin" value="Admin"><br> <br>
						</form>
					</div>
				</div>
				<div class="clr"></div>
			</div>
		</div>

		<div class="footer">
			<div class="footer_resize">
				<p class="lf">
					Copyright &copy; 2011 <a href="#">moSSSolutions</a> - All Rights
					Reserved
				</p>
				<p class="rf">
					Your web-based application provided by <a
						href="http://www.mosssolutions.wordpress.com">moSSSolutions</a>
				</p>
				<div class="clr"></div>
			</div>
		</div>
	</div>
</body>
</html>